package org.compactmvc.demo.view
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.text.TextField;
	
	import org.compactmvc.core.CompactMVC;
	import org.compactmvc.demo.ApplicationController;
	import org.compactmvc.demo.model.MainViewModel;
	import org.compactmvc.demo.view.helpers.MainButton;
	import org.compactmvc.viewpatterns.AbstractViewComponent;
	
	[Embed(source="./assets/assets.swf", symbol="MainViewMc")]
	public final class MainView extends AbstractViewComponent
	{	
		public static const NAME:String = 'MainView';
		
		public var controller:ApplicationController;
		public var mainButton:MainButton;
		public var mainButton2:MainButton;
		
		[Inject]
		public var model:MainViewModel;
		
		public function MainView()
		{
			super(NAME, ApplicationController.NAME, MainViewModel);
			
			//creating application controller before adding mainView to Stage!
			controller = new ApplicationController();
			
		}
		
		override protected function postRegisterHandler():void
		{
			//...
		}
		
		override protected function postRemoveHandler():void
		{
			//...
		}
	
		public function create():void
		{
			mainButton = new MainButton("button1");
			mainButton.buttonMode = true;
			mainButton.x = 100;
			mainButton.y = 100;
			addChild(mainButton);
			
			mainButton2 = new MainButton("button2");
			mainButton2.buttonMode = true;
			mainButton2.x = 200;
			mainButton2.y = 100;
			addChild(mainButton2);
			
			//text
			var tf:TextField = new TextField();
			tf.text = model.appModel.settingsData.textfield.text();
			tf.x = 100;
			tf.y = 150;
			addChild(tf);
		}
		
	}
}